package bairui.international.console.web.controller.index.module;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

import com.lianjing.sh.model.uml.model.status.State_UpDown;
import com.lianjing.sh.project.config.web.Project_Config_Web_PageTemplate;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.module.context.ModuleContext;
import com.lianjing.sh.spring.web.controller.enhance.navigations.context.NavigationContext;

import bairui.international.console.web.controller.index.module.image.C_Index_Module_Image_AddImage_Delete;
import bairui.international.console.web.controller.index.module.image.C_Index_Module_Image_AddImage_Down;
import bairui.international.console.web.controller.index.module.image.C_Index_Module_Image_AddImage_EditAccess;
import bairui.international.console.web.controller.index.module.image.C_Index_Module_Image_AddImage_FileUpload;
import bairui.international.console.web.controller.index.module.image.C_Index_Module_Image_AddImage_Page;
import bairui.international.console.web.controller.index.module.image.C_Index_Module_Image_AddImage_Publish;
import bairui.international.console.web.controller.index.module.image.C_Index_Module_Image_AddImage_Up;
import bairui.international.console.web.controller.index.module.product.C_Index_Module_Product_AddProduct_PageAccess;
import bairui.international.model.domain.jpa.TB_IndexModule;
import bairui.international.model.type.Type_IndexModule;
import bairui.international.service.Service_IndexModule;

/**
 *
 * 详情
 *
 * @generated
 * 
 * @see STest_C_Index_Module_Detail_DetailAccess 测试
 *
 */
@Controller
public class C_Index_Module_Detail_DetailAccess
 extends SC_Index_Module_Detail_DetailAccess 
{
	
	@Autowired private Service_IndexModule service_IndexModule;
	
	/**
	 * 访问详情页面
	 */
	@Action(DetailAccess.class)
	@GetMapping(DetailAccess.RequestMappingValue)
	public ModelAndView detailAccess(
		ModelMap map, HttpServletRequest request,
		@PathVariable(name=DetailAccess.PathVariableName.Id) long id,
		NavigationContext navigationContext, ModuleContext moduleContext
	) throws Exception {
		TB_IndexModule bean = service_IndexModule.findById(id);
		State_UpDown state = bean.getState();
		Type_IndexModule type = bean.getType();
		/* 模块 */
		moduleContext
			.addModule(module_Info.module(
					new Module_Info_OutputModel(bean),
					new C_Index_Module_Edit_EditAccess.EditAccess.Operate(){
						@Override public Object getId() {
							return id;
						}
					}, 
					new C_Index_Module_Product_AddProduct_PageAccess.PageAccess.Operate(){
						@Override public Object getModuleId() {
							return id;
						}
						@Override public boolean displaied() {
							if(type == Type_IndexModule.Product){
								return true;
							}
							return false;
						}
					},
					new C_Index_Module_Image_AddImage_FileUpload.FileUpload.Operate(){
						@Override public Object getModuleId() {
							return id;
						}
						@Override public boolean displaied() {
							if(type == Type_IndexModule.Img){
								return true;
							}
							return false;
						}
					},
					new C_Index_Module_Delete_Delete.Delete.Operate(){
						@Override public Object getId() { return id; }
					}, 
					new C_Index_Module_Publish_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public State_UpDown getState_UpDown() {
							return state;
						}
					}, 
					new C_Index_Module_Up_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public State_UpDown getState_UpDown() {
							return state;
						}
					}, 
					new C_Index_Module_Down_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public State_UpDown getState_UpDown() {
							return state;
						}
					}
				));
			/*
			 * 产品模块
			 */
			if(type == Type_IndexModule.Product){
				moduleContext
					.addModule(this.module_ProductPage.module(
							new C_Index_Module_Detail_ProductPage.ProductPage.Operate(){
								@Override public Object getId() {
									return id;
								}
							}, 
							new C_Index_Module_Detail_ProductEditAccess.ProductEditAccess.Operate(){
								@Override public Object getId() {
									return id;
								}
								@Override public Object getProductModuleId() {
									return "{{:id}}";
								}
							},
							new C_Index_Module_Detail_ProductDelete.ProductDelete.Operate(){
								@Override public Object getId() {
									return id;
								}
								@Override public Object getProductModuleId() {
									return "{{:id}}";
								}
							},
							new C_Index_Module_Detail_ProductPublish.ProductPublish.Operate(){
								@Override public Object getId() {
									return id;
								}
								@Override public Object getProductModuleId() {
									return "{{:id}}";
								}
							},
							new C_Index_Module_Detail_ProductUp.ProductUp.Operate(){
								@Override public Object getId() {
									return id;
								}
								@Override public Object getProductModuleId() {
									return "{{:id}}";
								}
							},
							new C_Index_Module_Detail_ProductDown.ProductDown.Operate(){
								@Override public Object getId() {
									return id;
								}
								@Override public Object getProductModuleId() {
									return "{{:id}}";
								}
							}
						));
			}else if(type == Type_IndexModule.Img){
				moduleContext
					.addModule(this.module_ImagePage.module(
							new C_Index_Module_Image_AddImage_Page.Page.Operate(){
								@Override public Object getModuleId() {
									return id;
								}
							}, 
							new C_Index_Module_Image_AddImage_EditAccess.EditAccess.Operate(){
								@Override public Object getModuleId() {
									return id;
								}
								@Override public Object getImgId() {
									return "{{:id}}";
								}
							},  
							new C_Index_Module_Image_AddImage_Delete.Delete.Operate(){
								@Override public Object getModuleId() {
									return id;
								}
								@Override public Object getImgId() {
									return "{{:id}}";
								}
							},
							new C_Index_Module_Image_AddImage_Publish.Publish.Operate(){
								@Override public Object getModuleId() {
									return id;
								}
								@Override public Object getImgId() {
									return "{{:id}}";
								}
							},
							new C_Index_Module_Image_AddImage_Up.Up.Operate(){
								@Override public Object getModuleId() {
									return id;
								}
								@Override public Object getImgId() {
									return "{{:id}}";
								}
							},
							new C_Index_Module_Image_AddImage_Down.Down.Operate(){
								@Override public Object getModuleId() {
									return id;
								}
								@Override public Object getImgId() {
									return "{{:id}}";
								}
							}
						));
			}
		//
		return Project_Config_Web_PageTemplate.Admin_Common(request);
	}
	

}
